<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[act_tj]){
$big_name_id=$_POST[big_name_id]?$_POST[big_name_id]:0;
$c_top_tj=$_POST[c_top_tj]?$_POST[c_top_tj]:0;
$c_tj=$_POST[c_tj]?$_POST[c_tj]:0;
mysql_query("insert into catalog (cat_name,big_name,big_name_id,c_ping,cat_id,c_top_tj,c_tj,dj,c_photo) values ('$_POST[cat_name]','$_POST[big_name]','$big_name_id','$_POST[c_ping]','$_POST[cat_id]','$c_top_tj','$c_tj','$_POST[dj]','$_POST[picture]')");

echo "<script>location='".$_POST[url]."';</script>";
}
?>
<?php
if($_POST['act_xg']){
$big_name_id=$_POST[big_name_id]?$_POST[big_name_id]:0;
$c_top_tj=$_POST[c_top_tj]?$_POST[c_top_tj]:0;
$c_tj=$_POST[c_tj]?$_POST[c_tj]:0;
mysql_query("update catalog set cat_name='$_POST[cat_name]',big_name='$_POST[big_name]',big_name_id='$big_name_id',c_ping='$_POST[c_ping]',cat_id='$_POST[cat_id]',c_top_tj='$c_top_tj',c_tj='$c_tj',c_photo='$_POST[picture]',dj='$_POST[dj]' where id='".$_POST['iid']."'");

echo "<script>location='".$_POST[url]."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">添加、修改产品目录&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
if($_GET[tj]){
?>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="catalog_modify.php" onSubmit="return check()" name="form1">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加产品目录</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">大类名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="big_name" type="text" id="big_name" size="30" maxlength="100">
      一级使用</td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">大类名称编号</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="big_name_id" type="text" id="big_name_id" size="8" maxlength="10">
        &nbsp;限数字0-5</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">产品目录名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="cat_name" type="text" id="cat_name" size="30" maxlength="100"></td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">首字拼音</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="c_ping" type="text" id="c_ping" size="10" maxlength="100"></td>
    </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="cat_id">
  <option value="0" selected>--选择上级目录--</option>
  <?php
  $sql="select * from catalog where cat_id=0 order by cat_name asc";
  $rs=mysql_query($sql);
  while($row=mysql_fetch_array($rs)){
  ?><option value="<?=$row['id']?>" <?php if($_GET[id]==$row['id']){echo "selected";}?>><?=$row[cat_name]?></option>
       <?php
         $sql2="select * from catalog where cat_id='".$row['id']."' order by cat_name asc";
		 $rs2=mysql_query($sql2);
		 while($row2=mysql_fetch_array($rs2)){
       ?><option value="<?=$row2['id']?>" <?php if($_GET[id]==$row2[id]){echo "selected";}?>>&nbsp;&nbsp;&nbsp;&nbsp;|--<?=$row2[cat_name]?></option>
  <?php
  }}
  ?>
      </select></td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">等级</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="dj">
	     <option value="1">1级</option>
	     <option value="2">2级</option>
	     <option value="3">3级</option>
	  </select><font color="#FF0000">一定要注意分级</font></td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">首页推荐</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input type="radio" name="c_top_tj" value="1">是&nbsp;&nbsp;<input name="c_top_tj" type="radio" value="0" checked>
        否</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">栏目推荐</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input type="radio" name="c_tj" value="1">是&nbsp;&nbsp;<input name="c_tj" type="radio" value="0" checked>
      否</td>
    </tr>
<TR>
    <TD align="center" bgColor="#FFFFFF" height="25">图片</TD>
    <TD bgColor="#f9f9f9"><INPUT name="picture" value="" size="35">
&nbsp;
<input name="button" type="button" onClick="window.open ('../admin_upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></TD>
  </TR>
    <tr><input type="hidden" name="url" value="<?=$url?>">
	<input type="hidden" name="act_tj" value="ok">
      <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
	</form>
  </table>
  <?php
}
?>
  <?php
if($_GET['xg']){
$sql="select * from catalog where id=".$_GET['xg_id'];
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
<table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="post" action="catalog_modify.php" onSubmit="return check()" name="form1">
      <tr>
        <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">修改产品目录</td>
      </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">大类名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="big_name" value="<?=$row[big_name]?>" type="text" id="big_name" size="30" maxlength="100">
        一级使用</td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">大类名称编号</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="big_name_id" type="text" id="big_name_id" value="<?=$row[big_name_id]?>" size="8" maxlength="10">
         限数字0-5</td>
    </tr>
      <tr>
        <td width="27%" height="30" align="center" bgcolor="#FFFFFF">产品目录名称</td>
        <td width="73%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="cat_name" type="text" value="<?=$row[cat_name]?>" size="30" maxlength="100"></td>
      </tr>
      <tr>
        <td width="27%" height="30" align="center" bgcolor="#FFFFFF">首字拼音</td>
        <td width="73%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="c_ping" type="text" value="<?=$row[c_ping]?>" size="10" maxlength="100"></td>
      </tr>
      <tr>
        <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
        <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="cat_id">
            <option value="0">--选择上级目录--</option>
  <?php
  $sql2="select * from catalog where cat_id=0 order by cat_name asc";
  $rs2=mysql_query($sql2);
  while($row2=mysql_fetch_array($rs2)){
  ?>
          <option value="<?=$row2['id']?>" <?php if($row2[id]==$row[cat_id]){echo "selected";}?>><?=$row2[cat_name]?></option>
  <?php
         $sql3="select * from catalog where cat_id='".$row2[id]."' order by cat_name asc";
		 $rs3=mysql_query($sql3);
		 while($row3=mysql_fetch_array($rs3)){
       ?><option value="<?=$row3['id']?>" <?php if($row3[id]==$row[cat_id]){echo "selected";}?>>&nbsp;&nbsp;&nbsp;&nbsp;|--<?=$row3[cat_name]?></option>
  <?php
  }
  mysql_free_result($rs3);
  }
  mysql_free_result($rs2);
  ?>
        </select></td>
      </tr>
	  <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">等级</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="dj">
	     <option value="1" <?php if($row[dj]==1){echo "selected";}?>>1级</option>
	     <option value="2" <?php if($row[dj]==2){echo "selected";}?>>2级</option>
	     <option value="3" <?php if($row[dj]==3){echo "selected";}?>>3级</option>
	  </select><font color="#FF0000">一定要注意分级</font></td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">首页推荐</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input type="radio" name="c_top_tj" value="1" <?php if($row[c_top_tj]==1){echo "checked";}?>>是&nbsp;&nbsp;<input name="c_top_tj" type="radio" value="0"  <?php if($row[c_top_tj]==0){echo "checked";}?>>
        否</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">栏目推荐</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input type="radio" name="c_tj" value="1" <?php if($row[c_tj]==1){echo "checked";}?>>是&nbsp;&nbsp;<input name="c_tj" type="radio" value="0"  <?php if($row[c_tj]==0){echo "checked";}?>>
      否</td>
    </tr>
<TR>
    <TD align="center" bgColor="#FFFFFF" height="25">图片</TD>
    <TD bgColor="#f9f9f9"><?php if($row[c_photo]){?><img src="http://www.sandib2b.cn/img/<?=$row[c_photo]?>" width="140" height="104" border="0"><br><?php }?><INPUT name="picture" value="<?=$row[c_photo]?>" size="35">
&nbsp;
<input name="button" type="button" onClick="window.open ('../admin_upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></TD>
  </TR>
      <tr><input type="hidden" name="url" value="<?=$url?>">
        <input type="hidden" name="act_xg" value="ok"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" value="提交"></td>
      </tr>
    </form>
  </table>
  <?php
}?>
<br>
<span style="color:#990000">注：工业品-1，消费品-2，农业-3，原材料-4，服务-5，二级以上为0</span>
</center>
</BODY>
</HTML>
